route.ts 672 B

1234567891011121314151617181920212223242526
  1. import { NextRequest, NextResponse } from "next/server";
  2. import { getLLMText } from "../../../lib/get-llm-text";
  3. import { source } from "../../../lib/source";
  4. export async function GET(
  5. _request: NextRequest,
  6. { params }: { params: Promise<{ slug: string[] }> },
  7. ) {
  8. const { slug } = await params;
  9. const page = source.getPage(slug);
  10. if (!page) {
  11. return new NextResponse("Page not found", { status: 404 });
  12. }
  13. const content = await getLLMText(page);
  14. return new NextResponse(content, {
  15. status: 200,
  16. headers: {
  17. "Content-Type": "text/plain; charset=utf-8",
  18. "Cache-Control": "public, max-age=3600", // Cache for 1 hour
  19. },
  20. });
  21. }